package com.example.qxfw.ybzz.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.example.qxfw.common.entity.qx.YbzzForecastFinal;
import com.example.qxfw.ybzz.mapper.YbzzForecastFinalMapper;
import com.example.qxfw.ybzz.service.YbzzForeCastFinalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
public class YbzzForecastFinalServiceImpl implements YbzzForeCastFinalService {

    @Autowired
    private YbzzForecastFinalMapper ybzzForecastFinalMapper;

    @Override
    public List<YbzzForecastFinal> listByParams(String dateChar1, String dateChar2, String stationId) {
        return ybzzForecastFinalMapper.selectByParams(Timestamp.valueOf(dateChar1),Timestamp.valueOf(dateChar2),stationId);
    }

    @Override
    public List<YbzzForecastFinal> listByParams1(String dateChar1, String dateChar2, String stationId) {
        return ybzzForecastFinalMapper.selectByParams1(Timestamp.valueOf(dateChar1),Timestamp.valueOf(dateChar2),stationId);
    }

    @Override
    public Integer update(YbzzForecastFinal ybzzForecastFinal) {
        LambdaUpdateWrapper<YbzzForecastFinal> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(YbzzForecastFinal::getStationid,ybzzForecastFinal.getStationid())
                .eq(YbzzForecastFinal::getForecasttype,ybzzForecastFinal.getForecasttype())
                .eq(YbzzForecastFinal::getNtimes,ybzzForecastFinal.getNtimes())
                .eq(YbzzForecastFinal::getDatechar,ybzzForecastFinal.getDatechar());
        int rows = ybzzForecastFinalMapper.update(ybzzForecastFinal,updateWrapper);
        return rows;
    }

    @Override
    public Integer delete(String shuZhiDate, String shuZhiEndDate, String intForecastType, String stationList) {
        int rows = ybzzForecastFinalMapper.delete(shuZhiDate,shuZhiEndDate,intForecastType,stationList);
        return rows;
    }

    @Override
    public Integer save(YbzzForecastFinal ybzzForecastFinal) {
        int rows = ybzzForecastFinalMapper.insert(ybzzForecastFinal);
        return rows;
    }
}
